package com.bckj.fastboot.auth.strategy;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class AuthStrategyFactory {

    public final static Map<String, AuthStrategy> AUTH_STRATEGY_MAP = new HashMap<>();

    public static Optional<AuthStrategy> getAuthStrategy(String authType) {
        return Optional.ofNullable(AUTH_STRATEGY_MAP.get(authType));
    }

    public static AuthStrategy getAuthStrategyOrThrow(String authType) {
        return getAuthStrategy(authType).orElseThrow(() -> new RuntimeException("authType not support"));
    }
}
